<!-- 考试 -->
<script setup>
import { Search } from '@element-plus/icons-vue'
import { ref } from 'vue'
import { useExamStore } from '@/stores/index'
const examStore = useExamStore()
import { useRouter } from 'vue-router'
const router = useRouter()

const inputValue = ref('')
const serach = () => {
  console.log(inputValue.value)
}

// 添加考试
const addExam = () => {
  window.open('https://www.wjx.cn/newwjx/manage/myquestionnaires.aspx?randomt=1719192899')
}

// 新建考试
const add = () => {
  router.push('/spendNotice')
}
</script>

<template>
  <el-card class="my-chapter">
    <div class="header">
      <div>
        <el-button type="primary" round @click="addExam">试卷库</el-button>
        <el-button type="primary" round @click="add">新建</el-button>
      </div>
      <el-input
        v-model="inputValue"
        :suffix-icon="Search"
        class="input-header"
        placeholder="搜索"
        @keyup.enter="serach"
      />
    </div>

    <div class="exam-list">
      <div class="exam-item-header">
        <el-select v-model="value" clearable placeholder="Select" style="width: 240px">
          <el-input
            v-model="inputValue"
            :suffix-icon="Search"
            class="input-class"
            placeholder="搜索"
            @keyup.enter="serach"
          />
          <el-option
            v-for="item in options"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          />
        </el-select>
      </div>
    </div>

    <div class="exam-text" v-for="item in examStore.examList" :key="item.classId">
      <div class="text-detail">
        <h2>试卷:</h2>
        <span>{{ item.title }}</span>
      </div>
      <div class="penson-detail">
        <el-button type="primary" round @click="addExam">查看</el-button>
      </div>
    </div>
  </el-card>
</template>

<style lang="scss" scoped>
.my-chapter {
  margin-top: 6.25rem;
  height: 100vh;

  // 头部
  .header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 1.25rem;
    height: 3.75rem;
    border-bottom: 1px solid #e2e2e2;

    .input-header {
      width: 200px;

      :deep(.el-input__wrapper) {
        border-radius: 50px;
      }
    }
  }

  // 通知
  .exam-list {
    margin-top: 1.25rem;
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    height: 100%;
    width: 100%;

    .exam-item-header {
      display: flex;
      gap: 1.25rem;
      justify-content: center;
      align-items: center;
    }
  }

  //   考试
  .exam-text {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    height: 100px;
    border-bottom: 1px solid #ccc;

    .text-detail {
      flex-direction: column;
    }

    .penson-detail {
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      gap: 1.25rem;
    }
  }
}
</style>
